//
//  YZMInfoViewController.m
//  YZMicroStock
//
//  Created by apple on 2017/9/20.
//  Copyright © 2017年 cqjr. All rights reserved.
//

#import "YZMInfoViewController.h"
#import "YZMHomePageCell.h"
#import "YZDKnowledgeViewController.h"

static NSString *const identifier = @"YZMHomePageCell";

@interface YZMInfoViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (weak, nonatomic) IBOutlet UITableView *myTableView;

@end

@implementation YZMInfoViewController{
    NSArray *_arrReviewData;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self configView];
}

- (void)configView{
    self.title = @"投资分析";
    [_myTableView registerNib:[UINib nibWithNibName:NSStringFromClass([YZMHomePageCell class]) bundle:nil] forCellReuseIdentifier:identifier];
    _myTableView.backgroundColor = [YZMAppStyle colorForMain];
    _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    NSString *path = [[NSBundle mainBundle] pathForResource:@"trade" ofType:@"json"];
    NSData *data = [[NSData alloc] initWithContentsOfFile:path];
    _arrReviewData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _arrReviewData.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    YZMHomePageCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
    NSDictionary *dic = _arrReviewData[indexPath.row];
    [cell configCellWithDic:dic];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 95;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSDictionary *dic = _arrReviewData[indexPath.row];
    [YZMHCMInstance pushViewControllerWithName:NSStringFromClass([YZDKnowledgeViewController class]) andParams:dic];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
